package com.ztk.threadbasic.completableFuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletableFuture01 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> future01 = CompletableFuture.runAsync(() -> {
            System.out.println("无返回值的runAsync方法");
        });
        // future01.get();
        // future01.join();

        CompletableFuture<String> future02 = CompletableFuture.supplyAsync(() -> {
            System.out.println("开始执行有返回值的异步调用superAsync");
            return "hello world";
        });

        System.out.println(future02.get());
    }
}
